<template>
	<view>
		<view class="baohan">
			<text class="biaoti">登录</text>
			<view class="geshi">
				<!-- 用户名输入框：添加 v-model="username" -->
				<view class="fangkuang">
					<text class="biaoqian">请输入用户名</text>
					<input type="text" class="shuru" placeholder="用户名" v-model="username">
				</view>
				<!-- 密码输入框：添加 v-model="password" -->
				<view class="fangkuang">
					<text class="biaoqian">请输入密码</text>
					<input type="password" class="shuru" placeholder="密码" v-model="password">
				</view>
				<button class="anniu anniuleixing" @click="denglu">登录</button>
				<text class="lianjie" @click="goDetailPage('register')">没有账号？去注册</text>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
		username: '', // 用户名变量
		password: ''  // 密码变量
		};
	},
	methods: {
				denglu() {
						// 验证用户名和密码是否为空
						if (!this.username || !this.password) {
							uni.showToast({
								title: '请填写用户名和密码',
								icon: 'none'
							});
							return;
						}
						uni.switchTab({
							url: '/pages/tabBar/component1/component1'
						});
					},
		goDetailPage(e) {
			if (typeof e === 'string') {
				uni.navigateTo({
					url: '/pages/components/' + e + '/' + e
				});
			} else {
				uni.navigateTo({
					url: e.url
				});
			}
		}
	}
};
</script>

<style>

</style>
